const event = {
  click: 'onclick',
  dblclick: 'ondblclick'
}

function isNumber(val) {
  var regPos = /^\d+(\.\d+)?$/; //非负浮点数
  var regNeg = /^(-(([0-9]+\.[0-9]*[1-9][0-9]*)|([0-9]*[1-9][0-9]*\.[0-9]+)|([0-9]*[1-9][0-9]*)))$/; //负浮点数
  if(regPos.test(val) || regNeg.test(val)) {
    return true;
  } else {
    return false;
  }
}

class Incident {
  constructor(vm, node, name, value) {
    this.node = node;
    this.vm = vm;
    this.name = name;
    this.value = value;

    if(/(.*)\(/.test(value)) {
      this.isMethods(name, RegExp.$1)
    } else {
      this.isMethods(name, value)
    }
  }
  isMethods(name, value) {
    // console.log(name, value, params)
    const vm = this.vm;
    if(vm.$methods && vm.$methods[value]) {
      this[name](vm.$methods[value])
    } else {
      console.log('木有找到当前函数')
    }
  }
  click(fn, value) {
    const params = [];
    this.node.onclick = () => {
      return fn.apply(this.vm, params) 
    }
  }
}